import Vue from 'vue'
import Vuex from 'vuex'
import cookies from "vue-cookies";

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    workspace: "",
    layer: "",
  },
  getters: {
    getWorkspace(state) {
        return state.workspace;
    },
    getLayer(state) {
        return state.layer;
    }
  },
  mutations: {
    setWorkspace(state, newWorkspace) {
        state.workspace = newWorkspace;
    },
    setLayer(state, newLayer) {
        state.layer = newLayer;
    }
  },
  actions: {
    setWorkspaceAndLayer(context, val) {
        if(val.workspace !== "" && val.layer !== ""){
            context.commit("setWorkspace", val.workspace);
            context.commit("setLayer", val.layer);
            cookies.set("isIn", "True");
        }
        else{
            cookies.set("isIn", "False");
        }
    }
  }

  ,
  modules: {
  }
})
